home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lantools
/
blueprnt
/
bpserial.asm
< prev
next >
Wrap
Assembly Source File
|
1990-01-30
|
5KB
|
171 lines
;************************************************************
;* BP-LAN Physical Layer for Serial I/O (BPSERIAL.ASM) *
;* by Craig Chaiken *
;* January 30, 1990 *
;* *
;* Function: *
;* Directly Controls Physical I/O on One Serial Port *
;* Command Format: *
;* BPSERIAL /io_base_addr /config_byte /baud_rate_word *
;************************************************************
;
include bpbioshd.mod
codeseg segment
assume cs:codeseg,ds:codeseg
org 100h
start: jmp install
in_stat dd 0
out_stat dd 0
;*** Byte Input/Output Drivers ***
;
in_byte proc near ;*** Receive Byte from Current Node ***
push dx
push ax
mov dx,cs:curport
add dx,5
getby1: in al,dx
test al,1
jz getby1
pop ax
mov dx,cs:curport
in al,dx
pop dx
bpbios link_int,calc_checksum
retf
in_byte endp
out_byte proc near ;*** Transmit Byte to Current Node ***
push ax
putby1: call cs:out_stat
jz putby1
call outport
pop ax
bpbios link_int,calc_checksum
retf
out_byte endp
;*** Hardware Level Input/Output Drivers ***
;
inport proc near ;*** Read Current Node's Data Port ***
push dx
mov dx,cs:curport
in al,dx
pop dx
ret
inport endp
outport proc near ;*** Write to Current Node's Data Port ***
push dx
mov dx,cs:curport
out dx,al
pop dx
ret
outport endp
in_status proc near ;*** Return NZ if Data in Receive Buffer ***
push ax
push dx
mov dx,cs:curport
add dx,5
in al,dx
test al,1
pop dx
pop ax
retf
in_status endp
out_status proc near ;*** Return NZ if Transmit Buffer is Empty ***
push ax
push dx
mov dx,cs:curport
add dx,5
in al,dx
test al,40h
pop dx
pop ax
retf
out_status endp
curport dw 03f8h
conf dw 3
brw dw 1
;*** End of Resident Code ***
setbaud proc near ;*** Set Baud Rate as Determined by BRW ***
push cx
push dx
mov dx,curport ;Divisor Latch = 1
add dx,3
mov al,80h
out dx,al
dec dx ;Disable Interrupts
mov al,0
out dx,al
mov cx,brw ;Output Baud Rate Word
mov dx,curport
mov al,cl
out dx,al
mov al,ch
inc dx
out dx,al
inc dx ;Configure UART
inc dx
mov ax,conf
out dx,al
pop dx
pop cx
push ax ;Setup Table for Faster Access to Status
mov ax,offset in_status
mov word ptr cs:in_stat,ax
pop ax
mov word ptr cs:in_stat+2,cs
push ax
mov ax,offset out_status
mov word ptr cs:out_stat,ax
pop ax
mov word ptr cs:out_stat+2,cs
ret
setbaud endp
include misc.mod
install proc near
mov al,cs:[80h] ;use default options if command line empty
or al,al
jz default
mov si,81h
call get_opt ;get serial I/O base port
jb default
mov cs:curport,cx
call get_opt ;get serial configuration byte
jb default
mov cs:conf,cx
call get_opt ;get baud rate word
jb default
mov cs:brw,cx
default:
call setbaud
mov al,receive_status
bpbios ctrl_int,install_port,,,offset in_status
mov al,transmit_status
bpbios ctrl_int,install_port,,,offset out_status
mov al,receive_byte
bpbios ctrl_int,install_port,,,offset in_byte
mov al,transmit_byte
bpbios ctrl_int,install_port,,,offset out_byte
bpbios ctrl_int,next_port
mov dx,offset setbaud
int 27h
install endp
codeseg ends
end start
;************************************************************
;* End of BPSERIAL.ASM *
;************************************************************